package com.innova_t.android.Jordi;

import java.util.ArrayList;

import android.content.Context;
import android.graphics.Bitmap;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class ImageAdapter extends BaseAdapter {
	private LayoutInflater mLayoutInflater;
	String path;
	Bitmap bmp;
	ArrayList<Bitmap> bitmapArray =  new ArrayList<Bitmap>(20);
	ArrayList<Persona> namesArray = new ArrayList<Persona>();
	
	public ImageAdapter(Context c){
		 mLayoutInflater=LayoutInflater.from(c);
	}
	
	@Override
	public int getCount() {
		return bitmapArray.size();
	}

	@Override
	public Object getItem(int position) {
		return null;
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}
	
	@Override
	public View getView(final int position, View _view, ViewGroup _group) {
		ViewHolder mVHolder;
		
    	if(_view == null){
    		_view = mLayoutInflater.inflate(R.layout.single_grid_item, _group, false);
    		mVHolder = new ViewHolder();
    		mVHolder.mImageView = (ImageView)_view.findViewById(R.id.imageView1);
    		mVHolder.mTextView = (TextView)_view.findViewById(R.id.textView1);
    		mVHolder.mImageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
    		mVHolder.mImageView.setPadding(8, 8, 8, 8);
    		_view.setTag(mVHolder);
		}else{
			mVHolder =(ViewHolder)_view.getTag();
		}
    	
		mVHolder.mImageView.setImageBitmap(bitmapArray.get(position));
		mVHolder.mTextView.setText(namesArray.get(position).getNombrePersona());
		return _view;
	}

	static class ViewHolder{
        ImageView mImageView;
        TextView mTextView;
    }
}
